#
import random
class Snake(object):
	def __init__(self):
		self.body = [[random.randint(100, 200)/10*10, random.randint(100, 200)/10*10]]
		#self.body.append([self.body[0][0]-10, self.body[0][1]])
		self.curDir = 2
		self.move = {'w':self.move_up, 'd':self.move_right, 's':self.move_down, 'a':self.move_left}
		self.tail = []
		self.l = 1
	
	def move_left(self, ledge, redge, t, b):
		self.body[0][0] -= 10
		if self.body[0][0] < ledge:
			self.body[0][0] = redge-10
	def move_right(self, ledge, redge, t, b):
		self.body[0][0] += 10
		if self.body[0][0] >= redge:
			self.body[0][0] = ledge
	
	def move_up(self, l, r,tedge, bedge):
		self.body[0][1] -= 10
		if self.body[0][1] < tedge:
			self.body[0][1] = bedge-10
	
	def move_down(self, l,r, tedge, bedge):
		self.body[0][1] += 10
		if self.body[0][1] >= bedge:
			self.body[0][1] = tedge
	
	def body_follow(self):
		for i in range(len(self.body)-1, 0, -1):
			self.body[i][0] = self.body[i-1][0]
			self.body[i][1] = self.body[i-1][1]
	
	def isBody(self, x, y):
		for i in xrange(0, len(self.body)):
			if x == self.body[i][0] and y == self.body[i][1]:
				return True
		return False
		
		
